{% extends 'base.html' %}  <!-- 用base.html作为母版 -->


{% block breadcrumb %}
  <li class="breadcrumb-item active">Boards</li>
{% endblock %}

{% block content %}
  <table class="table">
    <thead class="thead-dark">
      <tr>
        <th>专区</th>
        <th>帖子</th>
        <th>话题</th>
        <th>最新发布</th>
      </tr>
    </thead>
    <tbody>
      {% for board in boards %}
        <tr>
          <td>
            <a href="{% url 'board_topics' board.pk %}">{{ board.name }}</a>
            <small class="text-muted d-block">{{ board.description }}</small>
          </td>
          <td class="align-middle">{{ board.get_post_count }}</td>
          <td class="align-middle">{{ board.topics.count }}</td>
          <td class="align-middle">
            {% with post=board.get_last_post %}
              {% if post %}
                <small>
                  <a href="#" style="color: #fd7e14">
                    {{ post.create_by.username }}
                  </a>
                  于 {{ post.create_at }} 发布了一条帖子，
                  <a href="{% url 'topic_posts' board.pk post.topic.pk %}">
                    去看看！
                  </a>
                </small>
              {% else %}
                <small class="text-muted">
                  <em>快来分享一下吧！</em>
                </small>
              {% endif %}
            {% endwith %}
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% endblock %}